INCLUDE(UsePkgConfig)

PKGCONFIG(gtk+-2.0 GTK2_INCLUDE_DIR GTK2_LINK_DIR GTK2_LINK_FLAGS GTK2_CFLAGS)
PKGCONFIG(libglade-2.0 GLADE_INCLUDE_DIR GLADE_LINK_DIR GLADE_LINK_FLAGS GLADE_CFLAGS)
#PKGCONFIG(gthread-2.0 GTHREAD_INCLUDE_DIR GTHREAD_LINK_DIR GTHREAD_LINK_FLAGS+- GTHREAD_CFLAGS)

IF (GTK2_INCLUDE_DIR)
    SET(CMAKE_C_FLAGS "${GTK2_CFLAGS} ${GTHREAD_CFLAGS}")
    SET(CMAKE_CXX_FLAGS "${GTK2_CFLAGS} ${GTHREAD_CFLAGS}")
    STRING(REGEX REPLACE "-l" "" GTK_LIBRARIES "${GTK2_LINK_FLAGS} ${GTHREAD_LINK_FLAGS}")
    SEPARATE_ARGUMENTS(GTK_LIBRARIES)
    ADD_DEFINITIONS(-DHAVE_GTK2)
    MESSAGE("GTK 2.x found and used as GUI\n")
ELSE (GTK2_INCLUDE_DIR)
    MESSAGE(FATAL_ERROR "GTK or GTK2 is required to build this project.")
ENDIF (GTK2_INCLUDE_DIR)

IF (GLADE_INCLUDE_DIR)
    SET(CMAKE_C_FLAGS "${GLADE_CFLAGS} ${GTHREAD_CFLAGS}")
    SET(CMAKE_CXX_FLAGS "${GLADE_CFLAGS} ${GTHREAD_CFLAGS}")
    STRING(REGEX REPLACE "-l" "" GLADE_LIBRARIES "${GLADE_LINK_FLAGS} ${GTHREAD_LINK_FLAGS}")
    SEPARATE_ARGUMENTS(GLADE_LIBRARIES)
    ADD_DEFINITIONS(-DHAVE_GLADE)
    MESSAGE("GLADE 2.x found and used as GUI\n")
ELSE (GLADE_INCLUDE_DIR)
    MESSAGE(FATAL_ERROR "GLADE is required to build this project.")
ENDIF (GLADE_INCLUDE_DIR)

#FIND_PACKAGE(ITK REQUIRED)
#IF(ITK_FOUND)
# INCLUDE(${ITK_USE_FILE})
#ENDIF(ITK_FOUND)

#ADD_LIBRARY(deter callbacks.c support.c interface.c)
#ADD_LIBRARY(deter)

ADD_EXECUTABLE(funcviz funcviz.cc gui.cc util.cc)
TARGET_LINK_LIBRARIES(funcviz ${GTK2_LINK_FLAGS} ${GLADE_LINK_FLAGS})

ADD_EXECUTABLE(fvscript fvscript.cc trace_def.cc util.cc string_util.cc)
ADD_EXECUTABLE(fvtime fvtime.cc time_analyzer.cc)
